package com.sayice.design.FlyWeight;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Pool {
    Map <Integer,Rank>map=new HashMap<>();
    public void add(Customer a){
        Iterator it=map.keySet().iterator();
        while (it.hasNext()){
            int key=(int)it.next();
            if(map.get(key).equals(a.rank)) {
                map.put(a.id, map.get(key));
                return;
            }
        }
        map.put(a.id,a.rank);
    }
    public Rank get(int id){
        return map.get(id);
    }
}
